package hbt;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import entities.*;

public class HibernateUtil
{
    private static final SessionFactory sessionFactory;
    static
    {
        try
        {
        	 AnnotationConfiguration config = new AnnotationConfiguration();
        	  config.addAnnotatedClass(Rodamiento.class);
              config.addAnnotatedClass(Proveedor.class);
              config.addAnnotatedClass(OrdenDeCompra.class);
              config.addAnnotatedClass(DescuentoProveedor.class);
              config.addAnnotatedClass(DescuentoVolumenProv.class);
              config.addAnnotatedClass(DescuentoFrecuenciaProv.class);
              config.addAnnotatedClass(ListaCompra.class);
              config.addAnnotatedClass(ListaCompraOferta.class);
              config.addAnnotatedClass(ListaPrecio.class);
              config.addAnnotatedClass(ItemOrdenDeCompra.class);
              config.addAnnotatedClass(CondicionCompra.class);
              config.addAnnotatedClass(CompraContado.class);
              config.addAnnotatedClass(CompraEnCuotas.class);
              config.addAnnotatedClass(MovimientoStock.class);
              config.addAnnotatedClass(CondicionVenta.class);
              config.addAnnotatedClass(PagoContado.class);
              config.addAnnotatedClass(PagoEnCuotas.class);
              config.addAnnotatedClass(ItemSolicitud.class);
              config.addAnnotatedClass(Factura.class);
              config.addAnnotatedClass(ItemFactura.class);
              config.addAnnotatedClass(ItemPedido.class);
              config.addAnnotatedClass(PedidoCliente.class);
              config.addAnnotatedClass(Cliente.class);
              config.addAnnotatedClass(Remito.class);
              config.addAnnotatedClass(RemitoExterno.class);
              config.addAnnotatedClass(RemitoInterno.class);
              config.addAnnotatedClass(ItemRemito.class);
              config.addAnnotatedClass(SolicitudCotizacion.class);
              config.addAnnotatedClass(ListaPrecio.class);
              config.addAnnotatedClass(ItemCotizacion.class);
              config.addAnnotatedClass(DescuentoCliente.class);
              config.addAnnotatedClass(DescuentoVolumenCli.class);
              config.addAnnotatedClass(DescuentoFrecuenciaCli.class);
              config.addAnnotatedClass(Cotizacion.class);
              config.addAnnotatedClass(ItemLista.class);
              config.addAnnotatedClass(ODV.class);
              config.addAnnotatedClass(CPR.class);
              config.addAnnotatedClass(ComparativaDePrecios.class);
              config.addAnnotatedClass(ItemComparativa.class);
              config.addAnnotatedClass(Envio.class);
             sessionFactory = config.buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
  
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}
